import numpy as np
import jobs
jobs = reload( jobs )
import conecyl
conecyl = reload(conecyl)
from conecyl import ConeCyl
if __name__ == '__main__':
    ccnames = [\
               'r_100_h_200',
               'r_200_h_400',
               'r_400_h_800',
               'r_100_h_800', #slender
               'r_400_h_200', #short
              ]
    ploads = {'pl_010':  1.  ,
              'pl_020':  2.  ,
              'pl_030':  3.  ,
              'pl_040':  4.  ,
              'pl_050':  5.  ,
              'pl_060':  6.  ,
              'pl_070':  7.  ,
              'pl_080':  8.  ,
              'pl_090':  9.  ,
              'pl_100': 10.  ,
              'pl_110': 11.  ,
              'pl_120': 12.  ,
              'pl_130': 13.  ,
              'pl_140': 14.  ,
              'pl_150': 15.  ,
              'pl_160': 16.  ,
              'pl_170': 17.  ,
              'pl_180': 18.  ,
              'pl_190': 19.  ,
              'pl_200': 20.  ,
              'pl_210': 21.  ,
              'pl_220': 22.  ,
              'pl_230': 23.  ,
              'pl_240': 24.  ,
              'pl_250': 25.  }
    betadegs = {\
                'beta_n75': -75.,
                'beta_n60': -60.,
                'beta_n30': -30.,
                'beta_p00':   0.,
                'beta_p30':  30.,
                'beta_p60':  60.,
                'beta_p75':  75.,
               }
    ccs = {}
    for ccname in ccnames:
        for betadegname, betadeg in betadegs.iteritems():
            for ploadname, pload in ploads.iteritems():
                cc = ConeCyl()
                cc.name = ccname
                cc.fromDB()
                cc.betadeg = betadeg
                cc.pload = pload
                cc.numel_r = 240.
                cc.axialdispl = 10.
                cc.rebuild()
                cc.jobname = '_'.join( [ccname, betadegname, ploadname] )
                ccs[cc.jobname] = cc

    rannames = []
    for cc in ccs.values():
        if not cc.check_completed():        
            cc.create_model()
            rannames.append( cc.jobname )
            #cc.write_job( submit = False ) 
        #cc.read_disp_force()

    tmpf = open('study_spla_angle.py','w')
    jobs.print_waitForCompletion( rannames, tmpf )
    tmpf.close()
        
